//package com.example.demo.config.springsecurity;
//
//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
//import org.springframework.security.core.authority.AuthorityUtils;
//import org.springframework.security.core.context.SecurityContext;
//import org.springframework.security.core.context.SecurityContextHolder;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * 访问该接口自动登录
// */
//@RestController
//public class AuthController {
//    @RequestMapping("/auth")
//    public String auth() {
//        SecurityContext context = SecurityContextHolder.getContext();  //获取SecurityContext对象（当前会话肯定是没有登陆的）
//        //手动创建一个UsernamePasswordAuthenticationToken对象，也就是用户的认证信息，角色需要添加ROLE_前缀，权限直接写
//        UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("Test", null,
//                AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_user"));
//        context.setAuthentication(token);  //手动为SecurityContext设定认证信息
//        return "Login success！";
//    }
//}
